﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Rendering.RasterState
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;

#nullable disable
namespace UnityEngine.Rendering
{
  /// <summary>
  ///   <para>Values for the raster state.</para>
  /// </summary>
  /// <summary>
  ///   <para>Creates a new raster state with the given values.</para>
  /// </summary>
  /// <param name="cullingMode">Controls which sides of polygons should be culled (not drawn).</param>
  /// <param name="offsetUnits">Scales the minimum resolvable depth buffer value in the GPU's depth bias setting.</param>
  /// <param name="offsetFactor">Scales the maximum Z slope in the GPU's depth bias setting.</param>
  /// <param name="depthClip"></param>
  public struct RasterState(
    CullMode cullingMode = CullMode.Back,
    int offsetUnits = 0,
    float offsetFactor = 0.0f,
    bool depthClip = true) : IEquatable<RasterState>
  {
    /// <summary>
    ///   <para>Default values for the raster state.</para>
    /// </summary>
    public static readonly RasterState defaultValue = new RasterState();
    private CullMode m_CullingMode = cullingMode;
    private int m_OffsetUnits = offsetUnits;
    private float m_OffsetFactor = offsetFactor;
    private byte m_DepthClip = Convert.ToByte(depthClip);
    private byte m_Conservative = Convert.ToByte(false);
    private byte m_Padding1 = 0;
    private byte m_Padding2 = 0;

    /// <summary>
    ///   <para>Controls which sides of polygons should be culled (not drawn).</para>
    /// </summary>
    public CullMode cullingMode
    {
      get => this.m_CullingMode;
      set => this.m_CullingMode = value;
    }

    /// <summary>
    ///   <para>Enable clipping based on depth.</para>
    /// </summary>
    public bool depthClip
    {
      get => Convert.ToBoolean(this.m_DepthClip);
      set => this.m_DepthClip = Convert.ToByte(value);
    }

    /// <summary>
    ///   <para>Enables conservative rasterization. Before using check for support via SystemInfo.supportsConservativeRaster property.</para>
    /// </summary>
    public bool conservative
    {
      get => Convert.ToBoolean(this.m_Conservative);
      set => this.m_Conservative = Convert.ToByte(value);
    }

    /// <summary>
    ///   <para>Scales the minimum resolvable depth buffer value in the GPU's depth bias setting.</para>
    /// </summary>
    public int offsetUnits
    {
      get => this.m_OffsetUnits;
      set => this.m_OffsetUnits = value;
    }

    /// <summary>
    ///   <para>Scales the maximum Z slope in the GPU's depth bias setting.</para>
    /// </summary>
    public float offsetFactor
    {
      get => this.m_OffsetFactor;
      set => this.m_OffsetFactor = value;
    }

    public bool Equals(RasterState other)
    {
      return this.m_CullingMode == other.m_CullingMode && this.m_OffsetUnits == other.m_OffsetUnits && this.m_OffsetFactor.Equals(other.m_OffsetFactor) && (int) this.m_DepthClip == (int) other.m_DepthClip && (int) this.m_Conservative == (int) other.m_Conservative;
    }

    public override bool Equals(object obj)
    {
      return obj != null && obj is RasterState other && this.Equals(other);
    }

    public override int GetHashCode()
    {
      return ((((int) this.m_CullingMode * 397 ^ this.m_OffsetUnits) * 397 ^ this.m_OffsetFactor.GetHashCode()) * 397 ^ this.m_DepthClip.GetHashCode()) * 397 ^ this.m_Conservative.GetHashCode();
    }

    public static bool operator ==(RasterState left, RasterState right) => left.Equals(right);

    public static bool operator !=(RasterState left, RasterState right) => !left.Equals(right);
  }
}
